// 需要安装mockjs插件，指令为： cnpm i mockjs --save-dev （-dev指的是只在npm run serve测试用）
import Mock from 'mockjs'
// 设置一个请求接口为：localhost:8080/api/user/login,访问就返回对象{status:0,data{...}}
// 即相当于后端已经有了该接口，模拟接口请求返回相应的数据
// 相比本地加载静态xxx.json数据的好处：不需要修改代码，只需设置个const flag=false if(mock){require('./mock/api')},
// 当flag为true，则启动mock模拟接口请求数据；若后端已经生成好接口，只需将flag设为false则关闭模拟请求，别的代码不需要修改。
// 【推荐这种方式模拟接口请求】

/**首页查询商品列表-按产地查询 */
Mock.mock('/api/home/goods/area/list', {
  "code": 200,
  "msg": "操作成功",
  "data": {
    "China|10": [
      {
        "id": 2,
        "name": "腰乐",
        "pic": "/images/26A3FFA5AD1E45AE9D8B07AB138F764E.jpg",
        "price": 128.00,
        "promotionPrice": 99.00,
        "subTitle": "腰乐",
        "originalPrice": 158.00,
      }
    ],
    "Japan|10": [
      {
        "id": 2,
        "name": "腰乐",
        "pic": "/images/26A3FFA5AD1E45AE9D8B07AB138F764E.jpg",
        "price": 128.00,
        "promotionPrice": 99.00,
        "subTitle": "腰乐",
        "originalPrice": 158.00,
      }
    ],
    "Europe|10": [

      {
        "id": 2,
        "name": "腰乐",
        "pic": "/images/26A3FFA5AD1E45AE9D8B07AB138F764E.jpg",
        "price": 128.00,
        "promotionPrice": 99.00,
        "subTitle": "腰乐",
        "originalPrice": 158.00,
      }
    ]
  }
})

/**搜索商品 */
Mock.mock('/api/home/goods/keyword/list', {
  "code": 200,
  "msg": "操作成功",
  "data": {
    "records|10": [
      {
        "id": 2,
        "name": "腰乐",
        "pic": 'https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/f515ab05232ed14ccd78ec67e024495a.png',
        "price": 128.00,
        "promotionPrice": 99.00,
        "subTitle": "腰乐",
        "originalPrice": 158.00,
      }
    ],
    "total": 133,
    "size": 500,
    "current": 1,
    "pages": 1
  }
})


/**查询商品列表-期货现货列表 */


Mock.mock('/api/home/goods/list', {
  "code": 200,
  "msg": "操作成功",
  "data": {
    "records|10": [
      {
        "id": 2,
        "name": "腰乐",
        "pic": 'https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/f515ab05232ed14ccd78ec67e024495a.png',
        "price": 128.00,
        "promotionPrice": 99.00,
        "subTitle": "腰乐",
        "originalPrice": 158.00,
      }
    ],
    "total": 133,
    "size": 500,
    "current": 1,
    "pages": 1
  }
})

Mock.mock('/api/member/login',
  {
    "code": 200,
    "msg": "操作成功",
    "data": {
      "id": 675,
      "memberLevelId": null,
      "memberLevelName": null,
      "areaId": null,
      "areaName": null,
      "schoolName": null,
      "username": "test3",
      "password": "$2a$10$KzMXV4D5MWSLXi7ZCULQduEErVlJ2iWkeq3WLdCQsLt4jgCv5iK4m",
      "nickname": null,
      "phone": null,
      "status": null,
      "createTime": null,
      "icon": null,
      "gender": null,
      "birthday": null,
      "city": null,
      "job": null,
      "personalizedSignature": null,
      "sourceType": null,
      "integration": null,
      "roomNums": null,
      "roomDesc": null,
      "growth": null,
      "luckeyCount": null,
      "historyIntegration": null,
      "avatar": null,
      "weixinOpenid": null,
      "h5Openid": null,
      "appOpenid": null,
      "invitecode": null,
      "buyCount": null,
      "buyMoney": null,
      "storeId": null,
      "blance": null,
      "schoolId": null,
      "confimpassword": null,
      "phonecode": null,
      "buyCountss": null,
      "childList": null,
      "toMoney": null
    }
  })

Mock.mock('/api/member/register', {
  "code": 200,
  data: 10
})

Mock.mock('/api/carts', {
  "code": 200,
  data: {
    'list|8': [{
      'id|+1': 1,
      name: '@ctitle', // 随机生成一个中文标题
      'list|50': [{
        'id|+1': 236,
        img: '/imgs/item-box-1.png',
        name: '@ctitle' // 随机生成一个中文标题
      }]
    }]
  }
})
Mock.mock('/api/getCategory', {
  "code": 200,
  data: {
    'list|8': [{
      'id|+1': 1,
      name: '@ctitle', // 随机生成一个中文标题
      'list|50': [{
        'id|+1': 236,
        img: '/imgs/item-box-1.png',
        name: '@ctitle' // 随机生成一个中文标题
      }]
    }]
  }
})
Mock.mock('/api/products', {
  "code": 200,
  data: {
    'list|18-40': [{
      categoryId: 100012,
      id: 30,
      imageHost: 'http://img.springboot.cn',
      mainImage: 'https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/f515ab05232ed14ccd78ec67e024495a.png',
      name: '小米CC9',
      price: 1799,
      status: 1,
      subtitle: '3200万+4800万 前后双旗舰相机'
    }]
  }
})

Mock.mock('/api/orders', {
  "code": 200,
  data: {
    'list|10': [{
      closeTime: '',
      createTime: '2020-11-13 19:41:31',
      endTime: '',
      imageHost: null,
      'orderItemVoList|1-5': [
        {
          createTime: '2020-11-13 19:41:32',
          currentUnitPrice: 1399,
          orderNo: 1605267691953,
          productId: 36,
          productImage: 'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/6f2493e6c6fe8e2485c407e5d75e3651.jpg',
          productName: 'Redmi Note 8 Pro',
          quantity: 1,
          totalPrice: 1399
        }
      ],
      orderNo: 1605267691953,
      payment: 2398,
      paymentTime: '',
      paymentType: 1,
      paymentTypeDesc: '在线支付',
      postage: 0,
      receiverName: '陈先生',
      sendTime: '',
      shippingId: 3990,
      shippingVo: {
        receiverAddress: '前路',
        receiverCity: '台州',
        receiverDistrict: '椒江',
        receiverMobile: '18000000000',
        receiverName: '陈先生',
        receiverPhone: null,
        receiverProvince: '浙江',
        receiverZip: '322100'
      },
      status: 10,
      statusDesc: '未支付'
    }],
    total: 120
  }
})

Mock.mock('/api/collect', {
  "code": 200,
  data: {
    'list|10': [{
      'id': '270913',
      createTime: '2020-11-13 19:41:31',
      name: '@ctitle',// 随机生成一个中文标题
      endTime: '',
      img: 'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/6f2493e6c6fe8e2485c407e5d75e3651.jpg',
      orderNo: 1605267691953,
      payment: 2398,
      paymentTime: '',
      paymentType: 1,
      paymentTypeDesc: '在线支付',
      postage: 0,
      receiverName: '陈先生',
      sendTime: '',
      shippingId: 3990,

      status: 10,
      statusDesc: '未支付'
    }],
    total: 120
  }
})


